{include file="public/header" /}
<body>
	<div class="container text-center">
		<div class="row clearfix">
			<div class="col-md-12 column">
				<img src="https://img.php.cn/upload/avatar/000/000/001/5e8938fc8a7db289.png" />
			</div>
		</div>
	</div>
	<div class="container">
		<div class="row clearfix">
			<div class="col-md-12 column">
				<div class="form-group">
					<label for="phone">手机号</label>
					<input type="number" class="form-control" id="phone" placeholder="请输入11位手机号"/>
				</div>
				<div class="form-group">
					<label for="code">验证码</label>
					<div class="input-group">
						<input type="text" class="form-control" id="code" placeholder="请输入6位验证码"/>
						<span class="input-group-btn">
							<button id="regSendCode" class="btn btn-info" type="button" onclick="sendemail()">发送验证码</button>
						</span>
					</div>
				</div>
				<div class="form-group">
					<label for="pwd">密码</label>
					<input type="password" class="form-control" id="pwd" placeholder="请输入6-12位密码"/>
				</div>
				<button type="submit" class="btn btn-success btn-block" id="reg">注册</button>
			</div>
		</div>
		<div class="clearfix" style="margin-top:15px;">
			<a href="login" class="btn btn-default btn-link pull-right">登录</a>
		</div>
	</div>
	<script type="text/javascript">
		var regcountdown=30;
		function sendemail(){
			var phone = $("#phone").val();
			if(!phone){
				alert('请输入手机号');
				return false;
			}
			regSendCode= $("#regSendCode");
			settime(regSendCode);
		}
		function settime(regSendCode) {
			//发送验证码倒计时
			if(regcountdown == 0){
				regSendCode.removeClass('disabled');
				regSendCode.attr('onclick','sendemail()');
				regSendCode.html("获取验证码");
				regcountdown = 30;
				return;
			}else{
				regSendCode.addClass('disabled');
				regSendCode.removeAttr('onclick');
				regSendCode.html("重新发送("+regcountdown+")");
				regcountdown--;
			}
			setTimeout(function(){
				settime(regSendCode);
			},1000);
		}
		$("#reg").click(function(){
			var phone = $("#phone").val();
			var pwd = $("#pwd").val();
			var code = $("#code").val();
			$.post("/index.php/index/index/reg_json",{phone:phone,pwd:pwd,code:code},function(res){
				if(res.code != 0){
					alert(res.msg);
					return false;
				}
				alert('注册成功');
				window.location.href = '/index.php/index/index/index';
			},'json');
		})
	</script>
{include file="public/tail" /}